package com.xlh.dto.courseTest.experiment;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import com.xlh.service.statistic.impl.StatisticServiceimpl;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.security.core.parameters.P;

/**
 * @author sy
 */
@Data
@Accessors(chain = true)
@ToString
public class UserExperimentTimeInfoDTO {

    /**
     * 学生id
     */
     private Long userId;

    /**
     * 学生姓名
     */
    private String userName;

    /**
     * 课程ID
     */
    private Long courseId;

    /**
     * 班级ID
     */
    private Long classId;

    /**
     * 章节ID
     */
    private Long chapterId;

    /**
     * 任务Id
     */
    private Long taskId;

    /**
     * 学习时长
     */
     private String learnTime;

    /**
     * 视频时长
     */
    private String videoTime;


    /**
     * 学习时长
     */
    private String learnTimeStr;

    /**
     * 视频时长
     */
    private String videoTimeStr;



    /**
     * 初始化基础字段
     */
    public void initBaseColum(){
        if(ObjectUtil.isNull(this.getVideoTime())) this.setVideoTime("0");
        if(ObjectUtil.isNull(this.getLearnTime())) this.setLearnTime("0");
    }

    public void setTimeHourse(){
        if(ObjectUtil.isNull(learnTime)) {
            learnTime = "0";
        }
        if(ObjectUtil.isNull(learnTime)){
            videoTime = "0";
        }
        learnTimeStr = StatisticServiceimpl.convertTime(Double.valueOf(learnTime).longValue());
        videoTimeStr = StatisticServiceimpl.convertTime(Double.valueOf(videoTime).longValue());

        learnTime = String.valueOf(NumberUtil.div(Double.valueOf(learnTime), Double.valueOf(3600), 2));
        videoTime = String.valueOf(NumberUtil.div(Double.valueOf(videoTime), Double.valueOf(3600), 2));

    }

}
